package com.piccolo.wrapper.client.component.Overlay;

import java.util.ArrayList;
import java.util.List;

import com.google.gwt.core.client.JsArray;
import com.piccolo.wrapper.client.component.PLayer;
import com.piccolo.wrapper.client.component.PNode;
import com.piccolo.wrapper.client.component.PTransform;
import com.piccolo.wrapper.client.component.JSNI.PCameraJSNI;

public class PCameraOverlay extends PNodeOverlay
{
	private static PCameraJSNI impl = new PCameraJSNI(); 
	protected PCameraOverlay(){}
	public static PCameraOverlay create() { return impl.create(); }

	public final void animateViewToTransform(PTransformOverlay transform, double duration) 
	{
		impl.animateViewToTransform(this, transform, duration);
	}

	public final void addLayer(PLayer layer) 
	{
		impl.addLayer(this, layer.getOverlay());
	}
	
	public final void removeLayer(PLayer layer) 
	{
		impl.removeLayer(this, layer.getOverlay());	
	}
	
	public final List<PNode> getPickedNodes(double x, double y) 
	{
		List<PNode> result = new ArrayList<PNode>();
		JsArray<PNodeOverlay> nodes = impl.getPickedNodes(this);
		
		for (int i = 0; i < nodes.length(); i++)
			result.add(new PNode(nodes.get(i)));
		
		return result;
	}
	
	public final void setViewTransform(PTransform transform) 
	{
		impl.setViewTransform(this, transform.getOverlay());
	}
	
	public final List<PLayer> getLayers() 
	{
		List<PLayer> result = new ArrayList<PLayer>();
		JsArray<PLayerOverlay> layers = impl.getLayers(this);
		
		for (int i = 0; i < layers.length(); i++)
			result.add(new PLayer(layers.get(i)));
		
		return result;
	}

	public final int getLayerCount() 
	{
		return impl.getLayerCount(this);
	}
}
